package com.hil.okhtttp;

public class OkHttpClient2 {
    boolean isCanceled;
    Dispatcher2 dispatcher;
    int recount;
    public int getRecount() {
        return recount;
    }


    public boolean isCanceled() {
        return isCanceled;
    }

    public void setCanceled(boolean canceled) {
        isCanceled = canceled;
    }

    public Dispatcher2 getDispatcher() {
        return dispatcher;
    }

    public OkHttpClient2(Builder builder) {
        isCanceled = builder.isCanceled;
        dispatcher = builder.dispatcher;
    }

    public OkHttpClient2() {
        this(new Builder());
    }

    public final static class Builder{
        boolean isCanceled;
        Dispatcher2 dispatcher;
        int recount = 3; // 重试次数

        public void setRecount(int recount) {
            this.recount = recount;
        }

        public Builder() {
            dispatcher = new Dispatcher2();
        }

        public Builder dispatcher(Dispatcher2 dispatcher) {
            this.dispatcher = dispatcher;
            return this;
        }
        public Builder canceled(){
            isCanceled = true;
            return this;
        }
        public OkHttpClient2 build(){
            return new OkHttpClient2(this);
        }

    }


    public Call2 newCall(Request2 request2) {
        // RealCall
        return new RealCall2(this, request2);
    }


}
